<?php 
    require_once ('../connect.php');
    //接受传递的参数
    $username = $_POST['username'];
    $password = $_POST['password'];
    //查询用户
    $check_sql = "select username,password,sex from user where username='$username'";
    $result = $con->query($check_sql);
    $user_log_content = array(
        'username' => null,
        'sex' => null,
        'flag' => 0
    );
    $row = $result->fetch_assoc();
    if($row == null){
        $user_log_content['flag'] = 1;
        echo json_encode($user_log_content,JSON_UNESCAPED_UNICODE);
        return ;
    }
    else if($password != $row['password']){
            $user_log_content['flag'] = 2;
            echo json_encode($user_log_content,JSON_UNESCAPED_UNICODE);
        }
    else{
            $user_log_content['username'] = $row['username'];
            $user_log_content['sex'] = $row['sex'];
            echo json_encode($user_log_content,JSON_UNESCAPED_UNICODE);
        }
?>